package Tools.Pathfinding;

import org.newdawn.slick.util.pathfinding.PathFindingContext;
import org.newdawn.slick.util.pathfinding.TileBasedMap;

import Game.MapBlock;
import Game.MapBlock.EMapBlockType;
import GameMath.GSize;

/** Pathfinding map class
 * @author Aikidos
 */
public class PathfindingMap implements TileBasedMap {
	/** Map */
	private int[][] _map;
	
	/** Size of map */
	private GSize _mapSize = new GSize();
	
	public PathfindingMap(MapBlock[][] m, GSize mapSize) {
		_mapSize.set(mapSize);
		
		_map = new int[mapSize.width][mapSize.height];
		
		for (int i = 0; i < mapSize.width; i++)
            for (int j = 0; j < mapSize.height; j++)
            	_map[i][j] = (m[i][j].Type == EMapBlockType.Floor) ? 0 : 1;
	}

	/** Returns solid map
	 * @return Solid map
	 */
	public int[][] getSolidMap() {
		return _map;
	}
	
	@Override
	public boolean blocked(PathFindingContext ctx, int x, int y) {
		return _map[x][y] == 1;
	}

	@Override
	public float getCost(PathFindingContext ctx, int x, int y) {
		return 1.f;
	}

	@Override
	public int getHeightInTiles() {
		return _mapSize.height;
	}

	@Override
	public int getWidthInTiles() {
		return _mapSize.width;
	}

	@Override
	public void pathFinderVisited(int x, int y) {
		
	}

}
